<?php

class SettingsInstall
{
	
	private $_config = array(
		'name' => 'settings',
		'title' => 'Settings module',
		'dependencies' => array(
		),
		'import' => array(
			'application.modules.settings.SettingsModule',
			'application.modules.settings.models.Settings',
		)
	);
	
	public function config()
	{
		return $this->_config;
	}

	public function install()
	{
		$sql = "DROP TABLE IF EXISTS {{settings}};";
		Yii::app()->db->createCommand($sql)->execute();

		$sql="
	CREATE TABLE IF NOT EXISTS {{settings}} (
	  `id` int(11) NOT NULL AUTO_INCREMENT,
	  `category` varchar(64) NOT NULL DEFAULT 'system',
	  `key` varchar(255) NOT NULL,
	  `value` text NOT NULL,
	  PRIMARY KEY (`id`),
	  KEY `category_key` (`category`,`key`)
	) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
		Yii::app()->db->createCommand($sql)->execute();

	}

	public function uninstall()
	{
		Yii::app()->db->createCommand()->dropTable('{{settings}}');
	}
}